package com.apache.client;

import com.apache.api.vo.ResultEntity;
import com.apache.tools.ConfigUtil;

import java.util.Map;

/**
 * description:
 *
 * @author mhguo 创建时间：2016-10-20
 */
public class DictCoreClient {

    private static DictCoreClient instance;

    private static final String serviceName = "dictService";

    private String sysPass = "iussoft2018";

    private DictCoreClient() {
        sysPass = ConfigUtil.getInstance().interfacePass();
    }

    public static DictCoreClient getInstance() {
        if (null == instance) {
            instance = new DictCoreClient();
        }
        return (instance);
    }

    public ResultEntity dictSelect(Map<String, Object> dataMap) {
        dataMap.put("sysPass", sysPass);
        ResultEntity root = UctProtoclClient.getInstance()
                .doDictService(serviceName, "dictSelect", dataMap);
        return root;
    }

    /**
     * description:  获取地区信息
     */
    @SuppressWarnings("rawtypes")
    public Map dictCityInfo(Map<String, Object> dataMap) {
        dataMap.put("sysPass", sysPass);
        ResultEntity root = UctProtoclClient.getInstance()
                .doDictService(serviceName, "cityList", dataMap);
        if ("true".equals(root.getResult())) {
            return (Map) root.getEntity();
        }
        return null;
    }

    public Object dictItemInfo(Map<String, Object> dataMap) {
        dataMap.put("sysPass", sysPass);
        ResultEntity root = UctProtoclClient.getInstance()
                .doDictService(serviceName, "viewDictItem", dataMap);
        if ("true".equals(root.getResult())) {
            return root.getEntity();
        }
        return null;
    }

    public ResultEntity dictList(Map<String, Object> dataMap) {
        dataMap.put("sysPass", sysPass);
        ResultEntity root = UctProtoclClient.getInstance()
                .doDictService(serviceName, "dictList", dataMap);
        return root;
    }

}
